# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=sentinel-minipot
pkgver=2.3.0
pkgrel=1
pkgdesc="A minimal honeypot that emulates Telnet, HTTP, FTP and SMTP"
url="https://gitlab.nic.cz/turris/sentinel/minipot"
# ppc64le: fails to build
# s390x: blocked by logc-libs
arch="all !ppc64le !s390x"
license="GPL-3.0-or-later"
makedepends="
	argp-standalone
	autoconf
	automake
	base64c-dev
	czmq-dev
	gperf
	libevent-dev
	logc-dev
	logc-libs-dev
	msgpack-c-dev
	"
checkdepends="check-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="https://gitlab.nic.cz/turris/sentinel/minipot/-/archive/v$pkgver/minipot-v$pkgver.tar.bz2
	fix-configure-msgpack-c.patch
	no-valgrind.patch
	$pkgname.initd
	$pkgname.confd
	"
builddir="$srcdir/minipot-v$pkgver"

case "$CARCH" in
riscv64)
	# check() is disabled on the riscv64 package builder
	makedepends="$makedepends $checkdepends"
	;;
esac

prepare() {
	default_prepare

	./bootstrap
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-tests
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -D -m755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -D -m644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="
4f442240d413bdad2f6bddf5ef581c410f03842a4b50685be2e7d1d3686811a7644fd0787c26ee31cb99a0997f2867ed1375a6e3f2a2ede09bd5e9217fbe84d6  minipot-v2.3.0.tar.bz2
f9e127570d256ee9ce7f9f3d28a66cecfde2e0c9d068b68ea99599b0e3e74fb944311b3f69b28fea8f0b7c86ccba7094888f5310dbceb7ad44bf110b56060161  fix-configure-msgpack-c.patch
8b133216fa6d97d31105ecfecd3ffb3135c65e771c23968af1d186c6589fd3b31ea1866ed3d9bed34034b01f7322518fa4086503d3b12a0b3f8c21479ee46900  no-valgrind.patch
846e6c30949590026069df19b583847bc1f94d7190d6dd334ca7ae469323b63f94c82a8ff79b757618e656e5a12fa4b51fe25c6dae3344f8ee0eccaa7ffa324e  sentinel-minipot.initd
2cbdfc997d2f85ef6d24af2b4ce1aa7e01aebcb7e8fddc98d8b2401cba5138898e1668f4018c2609dbe88e35bbb1c1a61a9d3602e6f438e494706651f1ae4418  sentinel-minipot.confd
"
